<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>02非单文件组件</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <!-- 3 使用组件 -->
    <school></school>
    <student></student>
  </div>
  <div id="root">
    <student></student>
  </div>
  <script>
    // 1 创建school组件school
    const school = Vue.extend({
      template: `
      <div>
        <h1>学校</h1>
        <h3>{{schoolName}}</h3>
        <h3>{{addr}}</h3>
      </div>
      `,
      data() {
        return {
          schoolName: '清华',
          addr: '北京'
        }
      }
    })
    const student = Vue.extend({
      template: `
      <div>
        <h1>学生</h1>
        <h3>{{studentName}}</h3>
        <h3>{{age}}</h3>
      </div>
      `,
      data() {
        return {
          studentName: 'lqj',
          age: 18
        }
      }
    })
    Vue.component('student', student) // 注册全局组件student
    new Vue({
      el: '#app',
      // 2 注册局部组件
      components: {
        school
      }
    })
    new Vue({
      el: '#root'
    })
  </script>
</body>
</html>